package top.igotcha.chapter.chapter7;

import java.util.Arrays;
import java.util.List;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;

/**
 * @author Gotcha
 * @date 2021/3/12
 * @describe
 */
public class ShutdownTest {
    public static void main(String[] args) throws InterruptedException, ExecutionException {
        ExecutorService pool = Executors.newFixedThreadPool(2);
        Future<String> future1 = pool.submit(() -> {
                    System.out.println("任务1开始运行");
                    Thread.sleep(1000);
                    return "任务1OK"; });
        Future<String> future2 = pool.submit(() -> {
            System.out.println("任务2开始运行");
            Thread.sleep(500);
            return "任务2OK"; });
        Future<String> future3 = pool.submit(() -> {
            System.out.println("任务3开始运行");
            Thread.sleep(2000);
            return "任务3OK"; });


        //System.out.println(future1.get());
        //System.out.println(future2.get());
        //System.out.println(future3.get());

        //pool.shutdown();
        List<Runnable> runnables = pool.shutdownNow();
        System.out.println(runnables);
        pool.submit(()-> System.out.println("这条输出不出来"));
    }
}
